﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs"
    Inherits="CRM.Web.Admin.Page.BrandInfo.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
    <title></title>
    <link href="/Content/css/main.css" rel="stylesheet" type="text/css" />
    <link href="/Content/jquery/jquery-easyui-1.3/themes/default/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="/Content/jquery/jquery-easyui-1.3/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="/Content/jquery/jquery-easyui-1.3/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="/Content/jquery/jquery-easyui-1.3/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/Content/jquery/jquery-easyui-1.3/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/Content/jquery/artDialog/jquery.artDialog.source.js?skin=default" type="text/javascript"></script>
    <script src="/Content/jquery/artDialog/plugins/iframeTools.source.js?skin=default"
        type="text/javascript"></script>
    <script src="/Content/jquery/loading/loading.js" type="text/javascript"></script>
    <script src="/Content/jquery/json2.js" type="text/javascript"></script>
    <script type="text/javascript">

        var pageSizeGlobe = 20;

        //数据格式{"total":239,"rows":[]}
        $(document).ready(function () {
            $("#grid").datagrid({
                url: "/Ajax/ArticleInfoAjax.ashx",
                method: "post",
                title: "应用系统列表",
                loadMsg: "正在加载...",
                pagination: true,
                striped: true,
                rownumbers: true,
                region: "center",
                idField: "code",
                singleSelect: true,
                nowrap: true,
                fitColumns: true,
                queryParams: { "action": "ListFunc", "pageIndex": "1", "pageSize": pageSizeGlobe,"ArticleType":3  },
                columns: [[
//               { field: 'ArticleId', title: '序号', width: 100, formatter: function (key, row, rowindex){return key;}},
{ field: 'Title', title: '文章名称', width: 200, formatter: function (key, row, rowindex){return key;}},
{ field: 'Image', title: '关联图片', width: 100, formatter: function (key, row, rowindex){return "<img src='"+key+"' width='50' height='50' />";}},
{ field: 'CreateTime', title: '创建时间', width: 100, formatter: function (key, row, rowindex){return key;}},
{ field: 'IsNew', title: '是否最新', width: 40, formatter: function (key, row, rowindex){return key;}},
{ field: 'IsTop', title: '是否置顶', width: 40, formatter: function (key, row, rowindex){return key;}},
{ field: 'CreateUser', title: '发布人', width: 60, formatter: function (key, row, rowindex){return key;}},

               { field: "操作", title: '操作', width: 100, align: "center", formatter: function (key, row, rowindex) {
                   var edit = "<a href='javascript:Edit(" + row.ArticleId+ "," + rowindex + ")'>编辑</a> ";
                   var remove = "<a href='javascript:Remove(" + row.ArticleId + "," + rowindex + ")'>删除</a>";

                   return edit + remove;
               }
               }
             ]],
                toolbar: [
                           { text: "添加品牌案例", iconCls: "icon-add", handler: function () {
                               Add();
                           }
                       }
//                           ,
//                           { text: "导出", iconCls: "icon-print" },
//                           { text: "提示", iconCls: "icon-tip" }
                        ]
            });

            //分页事件
            $($("#grid").datagrid("getPager")).pagination({
                pageNumber: 1,
                pageList: [20, 40, 60],
                pageSize: pageSizeGlobe,
                showRefresh: false,
                onSelectPage: function (pagenumber, pagesize) {
                    pageSizeGlobe = pagesize;
                    Reload(pagenumber);
                }
            });
        });

        //页面刷新
        function Reload(pagenumber) {
            if (!pagenumber) {
                pagenumber = $("#grid").datagrid("getPager").find(".pagination-num").val();
            }

            $("#grid").datagrid("reload", $.extend($("#grid").datagrid("options").queryParams, {
                "action": "ListFunc",
                "pageIndex": pagenumber,
                "pageSize": pageSizeGlobe,
                "ArticleType":3
            }));
        }

        //删除操作
        function Remove(id, rowindex) {
			$.dialog.confirm("是否站的要删除？", function () {
                $.ajax({
                    type: "post",
                    data: {
                        action: "DeleteFunc",
                        ArticleId: id
                    },
                    url: "/Ajax/ArticleInfoAjax.ashx",
                    async: true,
                    beforeSend: function () {
                    },
                    success: function (data) {
                        if (data == "True") {
                            $("#grid").datagrid("deleteRow", rowindex);
                        } else {
                            $.dialog.alert('删除操作出现异常！');
                        }
                    },
                    error: function () {
                        $.dialog.alert('删除操作出现异常！');
                    }
                });                    
            });
            $.dialog.confirm("是否站的要删除？", function () {
			
                $("#grid").datagrid("deleteRow", rowindex);
            });
        }

        //编辑操作
        function Edit(id, rowindex) {
            $.dialog.open("/Page/BrandInfo/Edit.aspx?ArticleId=" + id, { id: "test",
                title: "编辑品牌案例",
                width: 900,
                height: 500,
                button: [{ name: "提交", callback: function (e) {
                    if (!$(e.document).find("iframe:eq(0)")[0].contentWindow._cnblogs_yixian_edit._submitFunc()) {
                        return false;
                    }
                    $.dialog({
                        content: "编辑成功",
                        icon: 'face-smile',
                        title: false,
                        cancel: false,
                        time: 1,
                        close: function () {
                            Reload();
                        }
                    });
                }
                }, { name: "取消", callback: function () { }
                }]
            });
        }

        //添加操作
        function Add() {
            var pager = $("#grid").datagrid("getPager");
            var pagenumber = $(pager).find(".pagination-num").val();

            $.dialog.open("/Page/BrandInfo/Add.aspx", { id: "test",
                title: "添加品牌案例",
                width: 900,
                height: 500,
                button: [{ name: "提交", callback: function (e) {
                    if (!$(e.document).find("iframe:eq(0)")[0].contentWindow._cnblogs_yixian_add._submitFunc()) {
                        return false;
                    }
                    $.dialog({
                        content: "添加成功",
                        icon: 'face-smile',
                        title: false,
                        cancel: false,
                        time: 1,
                        close: function () {
                            Reload(1);
                        }
                    });
                }
                }, { name: "取消", callback: function () { }
                }]
            });
        }
        
    </script>
</head>
<body class="easyui-layout">
    <div data-options="region:'center',iconCls:'icon-edit',border:true,split:true" style="padding: 5px;
        background: #eee">
        <table id="grid">
        </table>
    </div>
</body>
</html>